// 
// Bachelor of Software Engineering
// Media Design School
// Auckland
// New Zealand
//
// (c) 2005 - 2014 Media Design School
//
// File Name	: SpaceInvadersLogic.h
// Desrciption	: CSpaceInvadersLogic declaration file.
// Author		: Hayden Asplet.
// Mail			: hayden.asplet@mediadesignschool.com
//

#pragma once

#ifndef __SPACEINVADERSLOGIC_H__
#define __SPACEINVADERSLOGIC_H__

// Library Includes

// Local Includes
#include "AlienWave.h"
#include "HighscoreEntry.h"
#include "SpaceInvadersObjectComponents\SpaceInvadersObjectFactory.h"

class CSpaceInvadersLogic : public CGameLogic {
	// Member Functions
public:
	CSpaceInvadersLogic();
	virtual ~CSpaceInvadersLogic();

	virtual bool VInit();
	virtual void VUpdate(float _fDeltaTime);
	virtual void VChangeState(EGameState _eState);

	virtual void VRegisterEventListeners();
	virtual void VRemoveEventListeners();

	shared_ptr<CCannonComponent> GetCannonComponent();
	void LoadHighScores(const std::string& _krstrFilePath);
	void SaveHighScores(const std::string& _krstrFilePath);
	void CreateBunkers();

	// Event Listeners
	void OnCollisionEvent(TEventDataPtr _pEventData);
	void OnAnimationFinished(TEventDataPtr _pEventData);
	void OnDestroyObject(TEventDataPtr _pEventData);
protected:
	virtual CObjectFactory* VCreateObjectFactory();
private:

	// Member Variables
public:
protected:
private:
	CAlienWave m_alienWave;	// The wave of aliens.
	int m_iWavesCompleted;	// The amount of waves defeated.

	TGameObjectId m_cannonId;

	float m_fMysteryShipTime;		// The amount of time needed to surpass for next ship.
	float m_fMysteryShipTimeBuffer;	// The amount of time since last myster ship.

	bool m_bIsGameOver;

	std::vector<CHighScoreEntry> m_highscores;
};


#endif